#ifndef MAINWORKTHREAD_H
#define MAINWORKTHREAD_H
#include <QThread>
#include <QMutex>
#include "minicap.h"
#include "minitouch.h"

#define MODE_CAPTURE 1 << 0
#define MODE_TOUCH 1 << 1

#define STATUS_DISCONNECT 0
#define STATUS_CONNECTING 1
#define STATUS_CONNECTED  2

class MainWorkThread : public QThread
{
    Q_OBJECT

public:
    MainWorkThread(QObject *parent = nullptr);
    static MainWorkThread* getInstance();
    bool startMini(int mode);

signals:
    void statusChangeSignal(int mode, int cap_state, int touch_state, int ret);

protected:
    void run() override;

private:
    static QMutex mutex;
    static QAtomicPointer<MainWorkThread> instance;

    QMutex miniMutex;

    int workMode;
    MiniCap *miniCap;
    MiniTouch *miniTouch;
    int capStatus = STATUS_DISCONNECT;
    int touchStatus = STATUS_DISCONNECT;
};

#endif // MAINWORKTHREAD_H
